package com.eastfair.certificate.exceptioncode;

import com.eastfair.annotation.base.LanguageTypeEnum;
import com.eastfair.core.context.ContextUtil;
import com.eastfair.core.exception.code.BaseExceptionCode;

/**
 * 证件系统异常code定义
 * AABBBCCC   AA(19)  系统编号   BBB 模块    CCC 具体异常
 */
public enum CertificateExceptionCode implements BaseExceptionCode {

    /**
     * 认领模块 000
     */
    FIRST_AUTH_NULL(19000000, "不需要初次审核",""),
    SECOND_AUTH_NULL(19000001, "不需要最终审核",""),

    CERTIFICATE_NULL(19000002, "证件为空",""),

    CERTIFICATE_TEAM(19000005, "订单应由服务商创建",""),


    CERTIFICATE_FAILNO_ALL(19000003, "证件审核未通过",""),
    CERTIFICATE_COMPANY_ONLY(19000004, "不在同一个公司",""),
    /**
     * 证件已存在
     */
    CERTIFICATE_EXIT(19000012, "证件已存在", ""),

    ORDER_NUll(19000005, "订单为空",""),
    ORDER_PAY(19000006, "订单已经支付",""),
    ORDER_PAY_NO(19000007, "订单未支付",""),


    ORDER_EXIST(19000008, "订单已存在",""),

    INDEX_NUll(19000009, "指标不存在",""),
    INDEX_NO(19000010, "没有指标了",""),
    INDEX_TIME_NO(19000011, "指标时间重叠",""),
    ORDER_READY_PAY(19000012, "订单未预支付",""),
    ORDER_PRINT_NO(19000013, "订单未打印",""),



    PAYMENT_PLAN_EXCEED_COLLECT(18000001, "超出计划付款金额，请调整认领金额！",""),
    PAYMENT_RECORD_EXCEED_COLLECT(18000002, "超出付款记录金额，请调整认领金额！",""),
    UNKNOWEN_COLLECT_TYPE(18000003, "未知认领类型！",""),
    ALREADY_INVOICED(18000004, "合同已开票，不可取消认款！",""),


    FIRST_AUTH_CHECK(19000005, "请先完成初审",""),

    FIRST_AUTH_CHECK_FAIL(19000005, "初审失败，不能审核",""),

    BLACK_NULL(19000006, "制证不能加入黑名单",""),
    BLACK(19000007, "是黑名单不能审核","是黑名单不能审核"),
    ;

    private final int code;
    //中文消息
    private String msg;
    //英文消息
    private String enMsg;

    CertificateExceptionCode(int code, String msg, String enMsg) {
        this.code = code;
        this.msg = msg;
        this.enMsg = enMsg;
    }

    @Override
    public int getCode() {
        return code;
    }

    @Override
    public String getMsg() {
        //中英文切换
        if(LanguageTypeEnum.CN.name().equals(ContextUtil.getLanguageType())){
            //中文
            return msg;
        }else if(LanguageTypeEnum.EN.name().equals(ContextUtil.getLanguageType())){
            //英文
            return enMsg;
        }
        return msg;
    }


    public CertificateExceptionCode build(String msg, Object... param) {
        this.msg = String.format(msg, param);
        return this;
    }

    public CertificateExceptionCode param(Object... param) {
        msg = String.format(msg, param);
        return this;
    }


}
